package io.noties.markwon.plugin.notification


import io.noties.markwon.base.AbstractMarkwonPlugin
import io.noties.markwon.base.MarkwonConfiguration
import io.noties.markwon.base.MarkwonSpansFactory
import io.noties.markwon.base.MarkwonVisitor
import io.noties.markwon.base.RenderProps
import io.noties.markwon.base.SpanFactory
import io.noties.markwon.plugin.notification.model.NotificationBlock
import io.noties.markwon.plugin.notification.span.NotificationSpan
import org.commonmark.ext.gfm.strikethrough.Strikethrough
import org.commonmark.parser.Parser

class NotificationPlugin: AbstractMarkwonPlugin() {

    override fun configureParser(builder: Parser.Builder) {
        builder.extensions(setOf(NotificationsExtension.create()))
    }

    override fun configureSpansFactory(builder: MarkwonSpansFactory.Builder) {
        builder.setFactory(NotificationBlock::class.java, SpanFactory { configuration, props -> NotificationSpan() })
    }

    /*verride fun configureVisitor(builder: MarkwonVisitor.Builder) {
        builder.on(NotificationBlock::class.java, object : MarkwonVisitor.NodeVisitor<NotificationBlock> {
            override fun visit(visitor: MarkwonVisitor, strikethrough: NotificationBlock) {
                val length = visitor.length()
                visitor.visitChildren(strikethrough)
                visitor.setSpansForNodeOptional(strikethrough, length)

            }
        })
    }*/
}